﻿// This code is released under the BSD license.
namespace PugLib.UnitTest
{
    #region

    using Microsoft.VisualStudio.TestTools.UnitTesting;

    #endregion

    /// <summary>
    ///This is a test class for StringUtilitiesTest and is intended
    ///to contain all StringUtilitiesTest Unit Tests
    ///</summary>
    [TestClass]
    public class StringUtilitiesTest
    {
        /// <summary>
        ///A test for Trim
        ///</summary>
        [TestMethod]
        public void TrimTest()
        {
            const string input = "    a     ";
            const string expected = "a";
            string actual = StringUtilities.Trim(input);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for ToFriendlyName
        ///</summary>
        [TestMethod]
        public void ToFriendlyNameTest1()
        {
            const string input = "SomeUtilsText";
            const string expected = "Some Utils Text";
            string actual = StringUtilities.ToFriendlyName(input);
            Assert.AreEqual(expected, actual);
        }


        /// <summary>
        ///A test for Start
        ///</summary>
        [TestMethod]
        public void StartTest()
        {
            const string input = "abcd";
            const int length = 3;
            const string expected = "abc";
            string actual = StringUtilities.Start(input, length);
            Assert.AreEqual(expected, actual);
        }


        /// <summary>
        ///A test for IsNumeric
        ///</summary>
        [TestMethod]
        public void IsNumericTest()
        {
            object input = "627";
            bool actual = StringUtilities.IsNumeric(input);
            Assert.AreEqual(true, actual);

            input = "hi";
            actual = StringUtilities.IsNumeric(input);
            Assert.AreEqual(false, actual);
        }

        /// <summary>
        ///A test for IsEmpty
        ///</summary>
        [TestMethod]
        public void IsEmptyTest()
        {
            object input = null;
            bool actual = StringUtilities.IsEmpty(input);
            Assert.AreEqual(true, actual);

            input = new[] { "a", "b" };
            actual = StringUtilities.IsEmpty(input);
            Assert.AreEqual(false, actual);
        }

        /// <summary>
        ///A test for IsEmail
        ///</summary>
        [TestMethod]
        public void IsEmailTest()
        {
            string input = "someone@microsoft.com";
            bool actual = StringUtilities.IsEmail(input);
            Assert.AreEqual(true, actual);

            input = "no.com";
            actual = StringUtilities.IsEmail(input);
            Assert.AreEqual(false, actual);
        }


        [TestMethod]
        public void EndTest()
        {
            const string input = "12345";
            const int length = 2;
            const string expected = "45";
            string actual = StringUtilities.End(input, length);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ToTitleCaseTest()
        {
            const string Input = "i can has cheezeburger";
            const string expected = "I Can Has Cheezeburger";
            string actual = StringUtilities.ToTitleCase(Input);
            Assert.AreEqual(expected, actual);
        }
    }
}